package com.bop.dehong.base;

import com.bop.dehong.R;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @author YeFengYun
 * 
 * @describe Activity导航栏
 */
public class TopManager {

	private View mView;
	private ImageView top_bar_left;
	private ImageView top_bar_right;
	private TextView top_bar_left_txt;
	private TextView top_bar_title;
	private TextView top_bar_right_txt;

	public TopManager(View mView) {
		this.mView = mView;
		initView();
	}

	private void initView() {
		top_bar_left = (ImageView) mView.findViewById(R.id.top_bar_left);
		top_bar_right = (ImageView) mView.findViewById(R.id.top_bar_right);
		top_bar_left_txt = (TextView) mView.findViewById(R.id.top_bar_left_txt);
		top_bar_title = (TextView) mView.findViewById(R.id.top_bar_title);
		top_bar_right_txt = (TextView) mView
				.findViewById(R.id.top_bar_right_txt);
	}

	/**
	 * 左边图片可见
	 * 
	 * @param visibility
	 */
	public void setLeftImageVisibility(int visibility) {
		top_bar_left.setVisibility(visibility);
	}

	/**
	 * 右边图片可见
	 * 
	 * @param visibility
	 */
	public void setRightImageVisibility(int visibility) {
		top_bar_right.setVisibility(visibility);
	}

	/**
	 * 左边文字可见
	 * 
	 * @param visibility
	 */
	public void setLeftTextVisibility(int visibility) {
		top_bar_left_txt.setVisibility(visibility);
	}

	/**
	 * 右边文字可见
	 * 
	 * @param visibility
	 */
	public void setRightTextVisibility(int visibility) {
		top_bar_right_txt.setVisibility(visibility);
	}

	/**
	 * 中间文字可见
	 * 
	 * @param visibility
	 */
	public void setTitleVisibility(int visibility) {
		top_bar_title.setVisibility(visibility);
	}

	/**
	 * 左边图片
	 * 
	 * @param resId
	 */
	public void setLeftImageResource(int resId) {
		top_bar_left.setImageResource(resId);
	}

	/**
	 * 右边图片
	 * 
	 * @param resId
	 */
	public void setRightImageResource(int resId) {
		top_bar_right.setImageResource(resId);
	}

	/**
	 * 头部标题
	 * 
	 * @param text
	 */
	public void setTitle(CharSequence text) {
		top_bar_title.setText(text);
	}

	/**
	 * 头部标题
	 * 
	 * @param resid
	 */
	public void setTitle(int resid) {
		top_bar_title.setText(resid);
	}

	/**
	 * 左边文字
	 * 
	 * @param text
	 */
	public void setLeftText(CharSequence text) {
		top_bar_left_txt.setText(text);
	}

	/**
	 * 左边文字
	 * 
	 * @param resid
	 */
	public void setLeftText(int resid) {
		top_bar_left_txt.setText(resid);
	}

	/**
	 * 右边文字
	 * 
	 * @param text
	 */
	public void setRightText(CharSequence text) {
		top_bar_right_txt.setText(text);
	}

	/**
	 * 右边文字
	 * 
	 * @param resid
	 */
	public void setRightText(int resid) {
		top_bar_right_txt.setText(resid);
	}

	/**
	 * 左边文字点击事件
	 * 
	 * @param l
	 */
	public void setLeftTextOnClick(OnClickListener l) {
		top_bar_left_txt.setOnClickListener(l);
	}

	/**
	 * 右边图片点击事件
	 * 
	 * @param l
	 */
	public void setRightImageOnClick(OnClickListener l) {
		top_bar_right.setOnClickListener(l);
		setRightImageVisibility(View.VISIBLE);
	}

	/**
	 * 右边文字点击事件
	 * 
	 * @param l
	 */
	public void setRightTextOnClick(OnClickListener l) {
		top_bar_right_txt.setOnClickListener(l);
	}

}
